<template>
    <div class="login-page">
      <div class="lg-view">
        <el-form ref="form" :model="form" label-width="40px">
          <el-form-item label="帐号">
            <el-input v-model="form.userName"></el-input>
          </el-form-item>
          <el-form-item  label="密码">
            <el-input type="password" v-model="form.password"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button class="login-btn" round @click="toLogin">登录</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
</template>

<script>
  import { basePost } from '../../../base/request'
  import { handleLocalStorage } from '../../../base/baseApi'

  export default {
    name: 'Login',
    data () {
      return {
        form: {
          userName: null,
          password: null
        }
      }
    },
    methods: {
      toLogin () {
        /*
        * weichangxian/pb123456
        * */
        let _this = this
        basePost('/api/material/oauth/check_ssotoken', {
          ssotoken: '111',
          ssoid: '111',
          account: _this.form.userName
        }, (res) => {
          console.log(res)
          if (res.token) {
            handleLocalStorage('set', 'token', res.token)
            // handleLocalStorage('set', 'userName', _this.form.userName)
            setTimeout(() => {
              _this.$router.push({
                path: '/',
                query: {token: res.token, userId: _this.form.userName}
              })
            }, 500)
          }
        })
      }
    }
  }
</script>

<style scoped>
  .login-btn{
    width: 100%;
    background: #04be02;
    color: #fff;
  }
  .lg-view{
    padding: 15px;
  }
  .login-page{
    position: fixed;
    left: 0;
    top: 0;
    z-index: 900;
    background: #fff;
    width: 100vw;
    height: 100vh;
  }
</style>
